<template>
    <div v-if="AnimationList" class="Animation">
        <div v-if="loading" class="load animate__animated animate__fadeOut">
            <img :src="require('@/assets/images/loading/loading-small.gif')" alt="" />
            <span> loading... </span>
        </div>

        <transition-group v-else>
            <div class="list animate__animated animate__fadeInRight" v-for="(item, index) in AnimationList" :key="index" @click="playAnimation(item)">
                <div class="imgbase">
                    <img :src="'data:image/png;base64,' + item.image" alt="" />
                </div>
                <div class="title">
                    <span>
                        {{ item.name }}
                    </span>
                </div>
            </div>
        </transition-group>
    </div>
</template>

<script lang="ts" setup>
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useToolsStore } from '@/stores/tools'
import { getAnimationList } from '@/utils/getInoByVedio'
const toolsStore = useToolsStore()

// 导览缩略图及列表
const AnimationImages = ref()
// 播放导览
const playAnimation = (val: any) => {
    //参数：导览序号
    __g.camera.playAnimation(val.id)
}
const AnimationList = computed(() => toolsStore.animationList)

const loading = computed(() => toolsStore.animationList.length == 0)

onMounted(async () => {
    await getAnimationList()
})
onUnmounted(() => {
    __g.camera.stopAnimation()
})
</script>
<style lang="scss" scoped>
.Animation {
    position: absolute;
    @include Width(120);
    @include hHeight(800);
    @include Top(120);
    // @include left(0);
    @include Right(50);

    //   right: 0;
    margin: auto;
    //   display: flex;
    //   flex-wrap: wrap;
    //   justify-content: space-around;
    //   align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
    .list {
        @include Width(100);
        @include hHeight(100);
        flex-shrink: 0;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        @include BorderRadius(10);
        @include MarginLeft(10);
        @include MarginRight(10);
        @include MarginBottom(20);
        overflow: hidden;
        cursor: pointer;
        position: relative;
        &:hover img {
            transform: scale(1.2);
        }

        .imgbase {
            @include Width(100);
            @include hHeight(100);
            img {
                transition: all 0.5s;
                width: 100%;

                // height: 100%;
            }
        }

        .title {
            @include Width(100);
            // @include hHeight(20);
            // // @include MarginTop(10);
            text-align: center;
            position: absolute;
            @include Bottom(15);
        }
    }
    .load {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        @include Width(100);
        @include hHeight(100);
        @include BorderRadius(10);
        @include Margin(5, -10, 15, 10);
        border: 1px solid #fff;
        z-index: 12;

        img {
            transition: all 0.5s;
            @include Width(50);
            @include hHeight(50);
        }
        span {
            @include MarginTop(10);
        }
    }
}
</style>
